home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 52 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4dh93f$c3s@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 16 Jan 1996 22:33:19 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 17 Jan 96 00:50:13 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: operator T* amibiguities
  9. Organization: Sun Microsystems Inc.
  10. References: <r4ohs3kdek.fsf@erawan.cognex.com>
  11. Reply-To: clamage@Eng.Sun.COM
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMPxH3OEDnX0m9pzZAQHvsAF+NdVC0Da4JGO0CY2lEDlRka5dElMDXpnx
  14.     cKNA329DEWZeothakkBkVeJAp5lXPeVR
  15.     =K+tk
  16.  
  17. In article fsf@erawan.cognex.com, Michael Cook <mcook@cognex.com> writes:
  18. >Does the standards committee consider this code ambiguous:
  19.  
  20. >  struct X;
  21. >  struct Y
  22. >  {
  23. >      operator X*();
  24. >      operator const X*() const;
  25. >  };
  26. >  void* f(Y y)
  27. >  {
  28. >      return y; //10
  29. >  }
  30.  
  31. >A couple compilers (different vendors) say it /is/ ambiguous, but I can't
  32. >see why.
  33.  
  34. The ARM (and early versions of the C++ draft standard) said that any
  35. data pointer type could be converted implicitly to void*. Under that
  36. rule, the code is ambiguous.
  37.  
  38. That rule also allows silent loss of the const qualifier, which is wrong.
  39. The rule was changed so that there is no implicit conversion to void* from
  40. a cv-qualified pointer. Under the new rule, the code is not ambiguous, and
  41. the conversion to X* would be selected.
  42.  
  43. ---
  44. Steve Clamage, stephen.clamage@eng.sun.com
  45. ---
  46. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  47.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  48.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  49.